home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / alpha.bst < prev    next >
Text File  |  1988-01-22  |  22KB  |  1,258 lines

  1. % BibTeX standard bibliography style `alpha'
  2.     % version 0.99a for BibTeX versions 0.99a or later, LaTeX version 2.09.
  3.     % Copyright (C) 1985, all rights reserved.
  4.     % Copying of this file is authorized only if either
  5.     % (1) you make absolutely no changes to your copy, including name, or
  6.     % (2) if you do make changes, you name it something other than
  7.     % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst.
  8.     % This restriction helps ensure that all standard styles are identical.
  9.     % The file btxbst.doc has the documentation for this style.
  10.  
  11. ENTRY
  12.   { address
  13.     author
  14.     booktitle
  15.     chapter
  16.     edition
  17.     editor
  18.     howpublished
  19.     institution
  20.     journal
  21.     key
  22.     month
  23.     note
  24.     number
  25.     organization
  26.     pages
  27.     publisher
  28.     school
  29.     series
  30.     title
  31.     type
  32.     volume
  33.     year
  34.   }
  35.   {}
  36.   { label extra.label sort.label }
  37.  
  38. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  39.  
  40. FUNCTION {init.state.consts}
  41. { #0 'before.all :=
  42.   #1 'mid.sentence :=
  43.   #2 'after.sentence :=
  44.   #3 'after.block :=
  45. }
  46.  
  47. STRINGS { s t }
  48.  
  49. FUNCTION {output.nonnull}
  50. { 's :=
  51.   output.state mid.sentence =
  52.     { ", " * write$ }
  53.     { output.state after.block =
  54.     { add.period$ write$
  55.       newline$
  56.       "\newblock " write$
  57.     }
  58.     { output.state before.all =
  59.         'write$
  60.         { add.period$ " " * write$ }
  61.       if$
  62.     }
  63.       if$
  64.       mid.sentence 'output.state :=
  65.     }
  66.   if$
  67.   s
  68. }
  69.  
  70. FUNCTION {output}
  71. { duplicate$ empty$
  72.     'pop$
  73.     'output.nonnull
  74.   if$
  75. }
  76.  
  77. FUNCTION {output.check}
  78. { 't :=
  79.   duplicate$ empty$
  80.     { pop$ "empty " t * " in " * cite$ * warning$ }
  81.     'output.nonnull
  82.   if$
  83. }
  84.  
  85. FUNCTION {output.bibitem}
  86. { newline$
  87.   "\bibitem[" write$
  88.   label write$
  89.   "]{" write$
  90.   cite$ write$
  91.   "}" write$
  92.   newline$
  93.   ""
  94.   before.all 'output.state :=
  95. }
  96.  
  97. FUNCTION {fin.entry}
  98. { add.period$
  99.   write$
  100.   newline$
  101. }
  102.  
  103. FUNCTION {new.block}
  104. { output.state before.all =
  105.     'skip$
  106.     { after.block 'output.state := }
  107.   if$
  108. }
  109.  
  110. FUNCTION {new.sentence}
  111. { output.state after.block =
  112.     'skip$
  113.     { output.state before.all =
  114.     'skip$
  115.     { after.sentence 'output.state := }
  116.       if$
  117.     }
  118.   if$
  119. }
  120.  
  121. FUNCTION {not}
  122. {   { #0 }
  123.     { #1 }
  124.   if$
  125. }
  126.  
  127. FUNCTION {and}
  128. {   'skip$
  129.     { pop$ #0 }
  130.   if$
  131. }
  132.  
  133. FUNCTION {or}
  134. {   { pop$ #1 }
  135.     'skip$
  136.   if$
  137. }
  138.  
  139. FUNCTION {new.block.checka}
  140. { empty$
  141.     'skip$
  142.     'new.block
  143.   if$
  144. }
  145.  
  146. FUNCTION {new.block.checkb}
  147. { empty$
  148.   swap$ empty$
  149.   and
  150.     'skip$
  151.     'new.block
  152.   if$
  153. }
  154.  
  155. FUNCTION {new.sentence.checka}
  156. { empty$
  157.     'skip$
  158.     'new.sentence
  159.   if$
  160. }
  161.  
  162. FUNCTION {new.sentence.checkb}
  163. { empty$
  164.   swap$ empty$
  165.   and
  166.     'skip$
  167.     'new.sentence
  168.   if$
  169. }
  170.  
  171. FUNCTION {field.or.null}
  172. { duplicate$ empty$
  173.     { pop$ "" }
  174.     'skip$
  175.   if$
  176. }
  177.  
  178. FUNCTION {emphasize}
  179. { duplicate$ empty$
  180.     { pop$ "" }
  181.     { "{\em " swap$ * "}" * }
  182.   if$
  183. }
  184.  
  185. INTEGERS { nameptr namesleft numnames }
  186.  
  187. FUNCTION {format.names}
  188. { 's :=
  189.   #1 'nameptr :=
  190.   s num.names$ 'numnames :=
  191.   numnames 'namesleft :=
  192.     { namesleft #0 > }
  193.     { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't :=
  194.       nameptr #1 >
  195.     { namesleft #1 >
  196.         { ", " * t * }
  197.         { numnames #2 >
  198.         { "," * }
  199.         'skip$
  200.           if$
  201.           t "others" =
  202.         { " et~al." * }
  203.         { " and " * t * }
  204.           if$
  205.         }
  206.       if$
  207.     }
  208.     't
  209.       if$
  210.       nameptr #1 + 'nameptr :=
  211.       namesleft #1 - 'namesleft :=
  212.     }
  213.   while$
  214. }
  215.  
  216. FUNCTION {format.authors}
  217. { author empty$
  218.     { "" }
  219.     { author format.names }
  220.   if$
  221. }
  222.  
  223. FUNCTION {format.editors}
  224. { editor empty$
  225.     { "" }
  226.     { editor format.names
  227.       editor num.names$ #1 >
  228.     { ", editors" * }
  229.     { ", editor" * }
  230.       if$
  231.     }
  232.   if$
  233. }
  234.  
  235. FUNCTION {format.title}
  236. { title empty$
  237.     { "" }
  238.     { title "t" change.case$ }
  239.   if$
  240. }
  241.  
  242. FUNCTION {n.dashify}
  243. { 't :=
  244.   ""
  245.     { t empty$ not }
  246.     { t #1 #1 substring$ "-" =
  247.     { t #1 #2 substring$ "--" = not
  248.         { "--" *
  249.           t #2 global.max$ substring$ 't :=
  250.         }
  251.         {   { t #1 #1 substring$ "-" = }
  252.         { "-" *
  253.           t #2 global.max$ substring$ 't :=
  254.         }
  255.           while$
  256.         }
  257.       if$
  258.     }
  259.     { t #1 #1 substring$ *
  260.       t #2 global.max$ substring$ 't :=
  261.     }
  262.       if$
  263.     }
  264.   while$
  265. }
  266.  
  267. FUNCTION {format.date}
  268. { year empty$
  269.     { month empty$
  270.     { "" }
  271.     { "there's a month but no year in " cite$ * warning$
  272.       month
  273.     }
  274.       if$
  275.     }
  276.     { month empty$
  277.     'year
  278.     { month " " * year * }
  279.       if$
  280.     }
  281.   if$
  282. }
  283.  
  284. FUNCTION {format.btitle}
  285. { title emphasize
  286. }
  287.  
  288. FUNCTION {tie.or.space.connect}
  289. { duplicate$ text.length$ #3 <
  290.     { "~" }
  291.     { " " }
  292.   if$
  293.   swap$ * *
  294. }
  295.  
  296. FUNCTION {either.or.check}
  297. { empty$
  298.     'pop$
  299.     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  300.   if$
  301. }
  302.  
  303. FUNCTION {format.bvolume}
  304. { volume empty$
  305.     { "" }
  306.     { "volume" volume tie.or.space.connect
  307.       series empty$
  308.     'skip$
  309.     { " of " * series emphasize * }
  310.       if$
  311.       "volume and number" number either.or.check
  312.     }
  313.   if$
  314. }
  315.  
  316. FUNCTION {format.number.series}
  317. { volume empty$
  318.     { number empty$
  319.     { series field.or.null }
  320.     { output.state mid.sentence =
  321.         { "number" }
  322.         { "Number" }
  323.       if$
  324.       number tie.or.space.connect
  325.       series empty$
  326.         { "there's a number but no series in " cite$ * warning$ }
  327.         { " in " * series * }
  328.       if$
  329.     }
  330.       if$
  331.     }
  332.     { "" }
  333.   if$
  334. }
  335.  
  336. FUNCTION {format.edition}
  337. { edition empty$
  338.     { "" }
  339.     { output.state mid.sentence =
  340.     { edition "l" change.case$ " edition" * }
  341.     { edition "t" change.case$ " edition" * }
  342.       if$
  343.     }
  344.   if$
  345. }
  346.  
  347. INTEGERS { multiresult }
  348.  
  349. FUNCTION {multi.page.check}
  350. { 't :=
  351.   #0 'multiresult :=
  352.     { multiresult not
  353.       t empty$ not
  354.       and
  355.     }
  356.     { t #1 #1 substring$
  357.       duplicate$ "-" =
  358.       swap$ duplicate$ "," =
  359.       swap$ "+" =
  360.       or or
  361.     { #1 'multiresult := }
  362.     { t #2 global.max$ substring$ 't := }
  363.       if$
  364.     }
  365.   while$
  366.   multiresult
  367. }
  368.  
  369. FUNCTION {format.pages}
  370. { pages empty$
  371.     { "" }
  372.     { pages multi.page.check
  373.     { "pages" pages n.dashify tie.or.space.connect }
  374.     { "page" pages tie.or.space.connect }
  375.       if$
  376.     }
  377.   if$
  378. }
  379.  
  380. FUNCTION {format.vol.num.pages}
  381. { volume field.or.null
  382.   number empty$
  383.     'skip$
  384.     { "(" number * ")" * *
  385.       volume empty$
  386.     { "there's a number but no volume in " cite$ * warning$ }
  387.     'skip$
  388.       if$
  389.     }
  390.   if$
  391.   pages empty$
  392.     'skip$
  393.     { duplicate$ empty$
  394.     { pop$ format.pages }
  395.     { ":" * pages n.dashify * }
  396.       if$
  397.     }
  398.   if$
  399. }
  400.  
  401. FUNCTION {format.chapter.pages}
  402. { chapter empty$
  403.     'format.pages
  404.     { type empty$
  405.     { "chapter" }
  406.     { type "l" change.case$ }
  407.       if$
  408.       chapter tie.or.space.connect
  409.       pages empty$
  410.     'skip$
  411.     { ", " * format.pages * }
  412.       if$
  413.     }
  414.   if$
  415. }
  416.  
  417. FUNCTION {format.in.ed.booktitle}
  418. { booktitle empty$
  419.     { "" }
  420.     { editor empty$
  421.     { "In " booktitle emphasize * }
  422.     { "In " format.editors * ", " * booktitle emphasize * }
  423.       if$
  424.     }
  425.   if$
  426. }
  427.  
  428. FUNCTION {empty.misc.check}
  429. { author empty$ title empty$ howpublished empty$
  430.   month empty$ year empty$ note empty$
  431.   and and and and and
  432.   key empty$ not and
  433.     { "all relevant fields are empty in " cite$ * warning$ }
  434.     'skip$
  435.   if$
  436. }
  437.  
  438. FUNCTION {format.thesis.type}
  439. { type empty$
  440.     'skip$
  441.     { pop$
  442.       type "t" change.case$
  443.     }
  444.   if$
  445. }
  446.  
  447. FUNCTION {format.tr.number}
  448. { type empty$
  449.     { "Technical Report" }
  450.     'type
  451.   if$
  452.   number empty$
  453.     { "t" change.case$ }
  454.     { number tie.or.space.connect }
  455.   if$
  456. }
  457.  
  458. FUNCTION {format.article.crossref}
  459. { key empty$
  460.     { journal empty$
  461.     { "need key or journal for " cite$ * " to crossref " * crossref *
  462.       warning$
  463.       ""
  464.     }
  465.     { "In {\em " journal * "\/}" * }
  466.       if$
  467.     }
  468.     { "In " key * }
  469.   if$
  470.   " \cite{" * crossref * "}" *
  471. }
  472.  
  473. FUNCTION {format.crossref.editor}
  474. { editor #1 "{vv~}{ll}" format.name$
  475.   editor num.names$ duplicate$
  476.   #2 >
  477.     { pop$ " et~al." * }
  478.     { #2 <
  479.     'skip$
  480.     { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  481.         { " et~al." * }
  482.         { " and " * editor #2 "{vv~}{ll}" format.name$ * }
  483.       if$
  484.     }
  485.       if$
  486.     }
  487.   if$
  488. }
  489.  
  490. FUNCTION {format.book.crossref}
  491. { volume empty$
  492.     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  493.       "In "
  494.     }
  495.     { "Volume" volume tie.or.space.connect
  496.       " of " *
  497.     }
  498.   if$
  499.   editor empty$
  500.   editor field.or.null author field.or.null =
  501.   or
  502.     { key empty$
  503.     { series empty$
  504.         { "need editor, key, or series for " cite$ * " to crossref " *
  505.           crossref * warning$
  506.           "" *
  507.         }
  508.         { "{\em " * series * "\/}" * }
  509.       if$
  510.     }
  511.     { key * }
  512.       if$
  513.     }
  514.     { format.crossref.editor * }
  515.   if$
  516.   " \cite{" * crossref * "}" *
  517. }
  518.  
  519. FUNCTION {format.incoll.inproc.crossref}
  520. { editor empty$
  521.   editor field.or.null author field.or.null =
  522.   or
  523.     { key empty$
  524.     { booktitle empty$
  525.         { "need editor, key, or booktitle for " cite$ * " to crossref " *
  526.           crossref * warning$
  527.           ""
  528.         }
  529.         { "In {\em " booktitle * "\/}" * }
  530.       if$
  531.     }
  532.     { "In " key * }
  533.       if$
  534.     }
  535.     { "In " format.crossref.editor * }
  536.   if$
  537.   " \cite{" * crossref * "}" *
  538. }
  539.  
  540. FUNCTION {article}
  541. { output.bibitem
  542.   format.authors "author" output.check
  543.   new.block
  544.   format.title "title" output.check
  545.   new.block
  546.   crossref missing$
  547.     { journal emphasize "journal" output.check
  548.       format.vol.num.pages output
  549.       format.date "year" output.check
  550.     }
  551.     { format.article.crossref output.nonnull
  552.       format.pages output
  553.     }
  554.   if$
  555.   new.block
  556.   note output
  557.   fin.entry
  558. }
  559.  
  560. FUNCTION {book}
  561. { output.bibitem
  562.   author empty$
  563.     { format.editors "author and editor" output.check }
  564.     { format.authors output.nonnull
  565.       crossref missing$
  566.     { "author and editor" editor either.or.check }
  567.     'skip$
  568.       if$
  569.     }
  570.   if$
  571.   new.block
  572.   format.btitle "title" output.check
  573.   crossref missing$
  574.     { format.bvolume output
  575.       new.block
  576.       format.number.series output
  577.       new.sentence
  578.       publisher "publisher" output.check
  579.       address output
  580.     }
  581.     { new.block
  582.       format.book.crossref output.nonnull
  583.     }
  584.   if$
  585.   format.edition output
  586.   format.date "year" output.check
  587.   new.block
  588.   note output
  589.   fin.entry
  590. }
  591.  
  592. FUNCTION {booklet}
  593. { output.bibitem
  594.   format.authors output
  595.   new.block
  596.   format.title "title" output.check
  597.   howpublished address new.block.checkb
  598.   howpublished output
  599.   address output
  600.   format.date output
  601.   new.block
  602.   note output
  603.   fin.entry
  604. }
  605.  
  606. FUNCTION {inbook}
  607. { output.bibitem
  608.   author empty$
  609.     { format.editors "author and editor" output.check }
  610.     { format.authors output.nonnull
  611.       crossref missing$
  612.     { "author and editor" editor either.or.check }
  613.     'skip$
  614.       if$
  615.     }
  616.   if$
  617.   new.block
  618.   format.btitle "title" output.check
  619.   crossref missing$
  620.     { format.bvolume output
  621.       format.chapter.pages "chapter and pages" output.check
  622.       new.block
  623.       format.number.series output
  624.       new.sentence
  625.       publisher "publisher" output.check
  626.       address output
  627.     }
  628.     { format.chapter.pages "chapter and pages" output.check
  629.       new.block
  630.       format.book.crossref output.nonnull
  631.     }
  632.   if$
  633.   format.edition output
  634.   format.date "year" output.check
  635.   new.block
  636.   note output
  637.   fin.entry
  638. }
  639.  
  640. FUNCTION {incollection}
  641. { output.bibitem
  642.   format.authors "author" output.check
  643.   new.block
  644.   format.title "title" output.check
  645.   new.block
  646.   crossref missing$
  647.     { format.in.ed.booktitle "booktitle" output.check
  648.       format.bvolume output
  649.       format.number.series output
  650.       format.chapter.pages output
  651.       new.sentence
  652.       publisher "publisher" output.check
  653.       address output
  654.       format.edition output
  655.       format.date "year" output.check
  656.     }
  657.     { format.incoll.inproc.crossref output.nonnull
  658.       format.chapter.pages output
  659.     }
  660.   if$
  661.   new.block
  662.   note output
  663.   fin.entry
  664. }
  665.  
  666. FUNCTION {inproceedings}
  667. { output.bibitem
  668.   format.authors "author" output.check
  669.   new.block
  670.   format.title "title" output.check
  671.   new.block
  672.   crossref missing$
  673.     { format.in.ed.booktitle "booktitle" output.check
  674.       format.bvolume output
  675.       format.number.series output
  676.       format.pages output
  677.       address empty$
  678.     { organization publisher new.sentence.checkb
  679.       organization output
  680.       publisher output
  681.       format.date "year" output.check
  682.     }
  683.     { address output.nonnull
  684.       format.date "year" output.check
  685.       new.sentence
  686.       organization output
  687.       publisher output
  688.     }
  689.       if$
  690.     }
  691.     { format.incoll.inproc.crossref output.nonnull
  692.       format.pages output
  693.     }
  694.   if$
  695.   new.block
  696.   note output
  697.   fin.entry
  698. }
  699.  
  700. FUNCTION {conference} { inproceedings }
  701.  
  702. FUNCTION {manual}
  703. { output.bibitem
  704.   author empty$
  705.     { organization empty$
  706.     'skip$
  707.     { organization output.nonnull
  708.       address output
  709.     }
  710.       if$
  711.     }
  712.     { format.authors output.nonnull }
  713.   if$
  714.   new.block
  715.   format.btitle "title" output.check
  716.   author empty$
  717.     { organization empty$
  718.     { address new.block.checka
  719.       address output
  720.     }
  721.     'skip$
  722.       if$
  723.     }
  724.     { organization address new.block.checkb
  725.       organization output
  726.       address output
  727.     }
  728.   if$
  729.   format.edition output
  730.   format.date output
  731.   new.block
  732.   note output
  733.   fin.entry
  734. }
  735.  
  736. FUNCTION {mastersthesis}
  737. { output.bibitem
  738.   format.authors "author" output.check
  739.   new.block
  740.   format.title "title" output.check
  741.   new.block
  742.   "Master's thesis" format.thesis.type output.nonnull
  743.   school "school" output.check
  744.   address output
  745.   format.date "year" output.check
  746.   new.block
  747.   note output
  748.   fin.entry
  749. }
  750.  
  751. FUNCTION {misc}
  752. { output.bibitem
  753.   format.authors output
  754.   title howpublished new.block.checkb
  755.   format.title output
  756.   howpublished new.block.checka
  757.   howpublished output
  758.   format.date output
  759.   new.block
  760.   note output
  761.   fin.entry
  762.   empty.misc.check
  763. }
  764.  
  765. FUNCTION {phdthesis}
  766. { output.bibitem
  767.   format.authors "author" output.check
  768.   new.block
  769.   format.btitle "title" output.check
  770.   new.block
  771.   "PhD thesis" format.thesis.type output.nonnull
  772.   school "school" output.check
  773.   address output
  774.   format.date "year" output.check
  775.   new.block
  776.   note output
  777.   fin.entry
  778. }
  779.  
  780. FUNCTION {proceedings}
  781. { output.bibitem
  782.   editor empty$
  783.     { organization output }
  784.     { format.editors output.nonnull }
  785.   if$
  786.   new.block
  787.   format.btitle "title" output.check
  788.   format.bvolume output
  789.   format.number.series output
  790.   address empty$
  791.     { editor empty$
  792.     { publisher new.sentence.checka }
  793.     { organization publisher new.sentence.checkb
  794.       organization output
  795.     }
  796.       if$
  797.       publisher output
  798.       format.date "year" output.check
  799.     }
  800.     { address output.nonnull
  801.       format.date "year" output.check
  802.       new.sentence
  803.       editor empty$
  804.     'skip$
  805.     { organization output }
  806.       if$
  807.       publisher output
  808.     }
  809.   if$
  810.   new.block
  811.   note output
  812.   fin.entry
  813. }
  814.  
  815. FUNCTION {techreport}
  816. { output.bibitem
  817.   format.authors "author" output.check
  818.   new.block
  819.   format.title "title" output.check
  820.   new.block
  821.   format.tr.number output.nonnull
  822.   institution "institution" output.check
  823.   address output
  824.   format.date "year" output.check
  825.   new.block
  826.   note output
  827.   fin.entry
  828. }
  829.  
  830. FUNCTION {unpublished}
  831. { output.bibitem
  832.   format.authors "author" output.check
  833.   new.block
  834.   format.title "title" output.check
  835.   new.block
  836.   note "note" output.check
  837.   format.date output
  838.   fin.entry
  839. }
  840.  
  841. FUNCTION {default.type} { misc }
  842.  
  843. MACRO {jan} {"January"}
  844.  
  845. MACRO {feb} {"February"}
  846.  
  847. MACRO {mar} {"March"}
  848.  
  849. MACRO {apr} {"April"}
  850.  
  851. MACRO {may} {"May"}
  852.  
  853. MACRO {jun} {"June"}
  854.  
  855. MACRO {jul} {"July"}
  856.  
  857. MACRO {aug} {"August"}
  858.  
  859. MACRO {sep} {"September"}
  860.  
  861. MACRO {oct} {"October"}
  862.  
  863. MACRO {nov} {"November"}
  864.  
  865. MACRO {dec} {"December"}
  866.  
  867. MACRO {acmcs} {"ACM Computing Surveys"}
  868.  
  869. MACRO {acta} {"Acta Informatica"}
  870.  
  871. MACRO {cacm} {"Communications of the ACM"}
  872.  
  873. MACRO {ibmjrd} {"IBM Journal of Research and Development"}
  874.  
  875. MACRO {ibmsj} {"IBM Systems Journal"}
  876.  
  877. MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
  878.  
  879. MACRO {ieeetc} {"IEEE Transactions on Computers"}
  880.  
  881. MACRO {ieeetcad}
  882.  {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
  883.  
  884. MACRO {ipl} {"Information Processing Letters"}
  885.  
  886. MACRO {jacm} {"Journal of the ACM"}
  887.  
  888. MACRO {jcss} {"Journal of Computer and System Sciences"}
  889.  
  890. MACRO {scp} {"Science of Computer Programming"}
  891.  
  892. MACRO {sicomp} {"SIAM Journal on Computing"}
  893.  
  894. MACRO {tocs} {"ACM Transactions on Computer Systems"}
  895.  
  896. MACRO {tods} {"ACM Transactions on Database Systems"}
  897.  
  898. MACRO {tog} {"ACM Transactions on Graphics"}
  899.  
  900. MACRO {toms} {"ACM Transactions on Mathematical Software"}
  901.  
  902. MACRO {toois} {"ACM Transactions on Office Information Systems"}
  903.  
  904. MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
  905.  
  906. MACRO {tcs} {"Theoretical Computer Science"}
  907.  
  908. READ
  909.  
  910. FUNCTION {sortify}
  911. { purify$
  912.   "l" change.case$
  913. }
  914.  
  915. INTEGERS { len }
  916.  
  917. FUNCTION {chop.word}
  918. { 's :=
  919.   'len :=
  920.   s #1 len substring$ =
  921.     { s len #1 + global.max$ substring$ }
  922.     's
  923.   if$
  924. }
  925.  
  926. INTEGERS { et.al.char.used }
  927.  
  928. FUNCTION {initialize.et.al.char.used}
  929. { #0 'et.al.char.used :=
  930. }
  931.  
  932. EXECUTE {initialize.et.al.char.used}
  933.  
  934. FUNCTION {format.lab.names}
  935. { 's :=
  936.   s num.names$ 'numnames :=
  937.   numnames #1 >
  938.     { numnames #4 >
  939.     { #3 'namesleft := }
  940.     { numnames 'namesleft := }
  941.       if$
  942.       #1 'nameptr :=
  943.       ""
  944.     { namesleft #0 > }
  945.     { nameptr numnames =
  946.         { s nameptr "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  947.         { "{\etalchar{+}}" *
  948.           #1 'et.al.char.used :=
  949.         }
  950.         { s nameptr "{v{}}{l{}}" format.name$ * }
  951.           if$
  952.         }
  953.         { s nameptr "{v{}}{l{}}" format.name$ * }
  954.       if$
  955.       nameptr #1 + 'nameptr :=
  956.       namesleft #1 - 'namesleft :=
  957.     }
  958.       while$
  959.       numnames #4 >
  960.     { "{\etalchar{+}}" *
  961.       #1 'et.al.char.used :=
  962.     }
  963.     'skip$
  964.       if$
  965.     }
  966.     { s #1 "{v{}}{l{}}" format.name$
  967.       duplicate$ text.length$ #2 <
  968.     { pop$ s #1 "{ll}" format.name$ #3 text.prefix$ }
  969.     'skip$
  970.       if$
  971.     }
  972.   if$
  973. }
  974.  
  975. FUNCTION {author.key.label}
  976. { author empty$
  977.     { key empty$
  978.     { cite$ #1 #3 substring$ }
  979.     { key #3 text.prefix$ }
  980.       if$
  981.     }
  982.     { author format.lab.names }
  983.   if$
  984. }
  985.  
  986. FUNCTION {author.editor.key.label}
  987. { author empty$
  988.     { editor empty$
  989.     { key empty$
  990.         { cite$ #1 #3 substring$ }
  991.         { key #3 text.prefix$ }
  992.       if$
  993.     }
  994.     { editor format.lab.names }
  995.       if$
  996.     }
  997.     { author format.lab.names }
  998.   if$
  999. }
  1000.  
  1001. FUNCTION {author.key.organization.label}
  1002. { author empty$
  1003.     { key empty$
  1004.     { organization empty$
  1005.         { cite$ #1 #3 substring$ }
  1006.         { "The " #4 organization chop.word #3 text.prefix$ }
  1007.       if$
  1008.     }
  1009.     { key #3 text.prefix$ }
  1010.       if$
  1011.     }
  1012.     { author format.lab.names }
  1013.   if$
  1014. }
  1015.  
  1016. FUNCTION {editor.key.organization.label}
  1017. { editor empty$
  1018.     { key empty$
  1019.     { organization empty$
  1020.         { cite$ #1 #3 substring$ }
  1021.         { "The " #4 organization chop.word #3 text.prefix$ }
  1022.       if$
  1023.     }
  1024.     { key #3 text.prefix$ }
  1025.       if$
  1026.     }
  1027.     { editor format.lab.names }
  1028.   if$
  1029. }
  1030.  
  1031. FUNCTION {calc.label}
  1032. { type$ "book" =
  1033.   type$ "inbook" =
  1034.   or
  1035.     'author.editor.key.label
  1036.     { type$ "proceedings" =
  1037.     'editor.key.organization.label
  1038.     { type$ "manual" =
  1039.         'author.key.organization.label
  1040.         'author.key.label
  1041.       if$
  1042.     }
  1043.       if$
  1044.     }
  1045.   if$
  1046.   duplicate$
  1047.   year field.or.null purify$ #-1 #2 substring$
  1048.   *
  1049.   'label :=
  1050.   year field.or.null purify$ #-1 #4 substring$
  1051.   *
  1052.   sortify 'sort.label :=
  1053. }
  1054.  
  1055. FUNCTION {sort.format.names}
  1056. { 's :=
  1057.   #1 'nameptr :=
  1058.   ""
  1059.   s num.names$ 'numnames :=
  1060.   numnames 'namesleft :=
  1061.     { namesleft #0 > }
  1062.     { nameptr #1 >
  1063.     { "   " * }
  1064.     'skip$
  1065.       if$
  1066.       s nameptr "{vv{ } }{ll{ }}{  ff{ }}{  jj{ }}" format.name$ 't :=
  1067.       nameptr numnames = t "others" = and
  1068.     { "et al" * }
  1069.     { t sortify * }
  1070.       if$
  1071.       nameptr #1 + 'nameptr :=
  1072.       namesleft #1 - 'namesleft :=
  1073.     }
  1074.   while$
  1075. }
  1076.  
  1077. FUNCTION {sort.format.title}
  1078. { 't :=
  1079.   "A " #2
  1080.     "An " #3
  1081.       "The " #4 t chop.word
  1082.     chop.word
  1083.   chop.word
  1084.   sortify
  1085.   #1 global.max$ substring$
  1086. }
  1087.  
  1088. FUNCTION {author.sort}
  1089. { author empty$
  1090.     { key empty$
  1091.     { "to sort, need author or key in " cite$ * warning$
  1092.       ""
  1093.     }
  1094.     { key sortify }
  1095.       if$
  1096.     }
  1097.     { author sort.format.names }
  1098.   if$
  1099. }
  1100.  
  1101. FUNCTION {author.editor.sort}
  1102. { author empty$
  1103.     { editor empty$
  1104.     { key empty$
  1105.         { "to sort, need author, editor, or key in " cite$ * warning$
  1106.           ""
  1107.         }
  1108.         { key sortify }
  1109.       if$
  1110.     }
  1111.     { editor sort.format.names }
  1112.       if$
  1113.     }
  1114.     { author sort.format.names }
  1115.   if$
  1116. }
  1117.  
  1118. FUNCTION {author.organization.sort}
  1119. { author empty$
  1120.     { organization empty$
  1121.     { key empty$
  1122.         { "to sort, need author, organization, or key in " cite$ * warning$
  1123.           ""
  1124.         }
  1125.         { key sortify }
  1126.       if$
  1127.     }
  1128.     { "The " #4 organization chop.word sortify }
  1129.       if$
  1130.     }
  1131.     { author sort.format.names }
  1132.   if$
  1133. }
  1134.  
  1135. FUNCTION {editor.organization.sort}
  1136. { editor empty$
  1137.     { organization empty$
  1138.     { key empty$
  1139.         { "to sort, need editor, organization, or key in " cite$ * warning$
  1140.           ""
  1141.         }
  1142.         { key sortify }
  1143.       if$
  1144.     }
  1145.     { "The " #4 organization chop.word sortify }
  1146.       if$
  1147.     }
  1148.     { editor sort.format.names }
  1149.   if$
  1150. }
  1151.  
  1152. FUNCTION {presort}
  1153. { calc.label
  1154.   sort.label
  1155.   "    "
  1156.   *
  1157.   type$ "book" =
  1158.   type$ "inbook" =
  1159.   or
  1160.     'author.editor.sort
  1161.     { type$ "proceedings" =
  1162.     'editor.organization.sort
  1163.     { type$ "manual" =
  1164.         'author.organization.sort
  1165.         'author.sort
  1166.       if$
  1167.     }
  1168.       if$
  1169.     }
  1170.   if$
  1171.   *
  1172.   "    "
  1173.   *
  1174.   year field.or.null sortify
  1175.   *
  1176.   "    "
  1177.   *
  1178.   title field.or.null
  1179.   sort.format.title
  1180.   *
  1181.   #1 entry.max$ substring$
  1182.   'sort.key$ :=
  1183. }
  1184.  
  1185. ITERATE {presort}
  1186.  
  1187. SORT
  1188.  
  1189. STRINGS { longest.label last.sort.label next.extra }
  1190.  
  1191. INTEGERS { longest.label.width last.extra.num }
  1192.  
  1193. FUNCTION {initialize.longest.label}
  1194. { "" 'longest.label :=
  1195.   #0 int.to.chr$ 'last.sort.label :=
  1196.   "" 'next.extra :=
  1197.   #0 'longest.label.width :=
  1198.   #0 'last.extra.num :=
  1199. }
  1200.  
  1201. FUNCTION {forward.pass}
  1202. { last.sort.label sort.label =
  1203.     { last.extra.num #1 + 'last.extra.num :=
  1204.       last.extra.num int.to.chr$ 'extra.label :=
  1205.     }
  1206.     { "a" chr.to.int$ 'last.extra.num :=
  1207.       "" 'extra.label :=
  1208.       sort.label 'last.sort.label :=
  1209.     }
  1210.   if$
  1211. }
  1212.  
  1213. FUNCTION {reverse.pass}
  1214. { next.extra "b" =
  1215.     { "a" 'extra.label := }
  1216.     'skip$
  1217.   if$
  1218.   label extra.label * 'label :=
  1219.   label width$ longest.label.width >
  1220.     { label 'longest.label :=
  1221.       label width$ 'longest.label.width :=
  1222.     }
  1223.     'skip$
  1224.   if$
  1225.   extra.label 'next.extra :=
  1226. }
  1227.  
  1228. EXECUTE {initialize.longest.label}
  1229.  
  1230. ITERATE {forward.pass}
  1231.  
  1232. REVERSE {reverse.pass}
  1233.  
  1234. FUNCTION {begin.bib}
  1235. { et.al.char.used
  1236.     { "\newcommand{\etalchar}[1]{$^{#1}$}" write$ newline$ }
  1237.     'skip$
  1238.   if$
  1239.   preamble$ empty$
  1240.     'skip$
  1241.     { preamble$ write$ newline$ }
  1242.   if$
  1243.   "\begin{thebibliography}{"  longest.label  * "}" * write$ newline$
  1244. }
  1245.  
  1246. EXECUTE {begin.bib}
  1247.  
  1248. EXECUTE {init.state.consts}
  1249.  
  1250. ITERATE {call.type$}
  1251.  
  1252. FUNCTION {end.bib}
  1253. { newline$
  1254.   "\end{thebibliography}" write$ newline$
  1255. }
  1256.  
  1257. EXECUTE {end.bib}
  1258.